// const cdn = {
//   css: [
//     'https://cdn.bootcdn.net/ajax/libs/ant-design-vue/2.0.0-rc.5/antd.min.css'
//   ],
//   js: [
//     'https://cdn.bootcdn.net/ajax/libs/vue/3.0.2/vue.global.prod.js',
//     'https://cdn.bootcdn.net/ajax/libs/ant-design-vue/2.0.0-rc.5/antd.min.js',
//     'https://cdn.bootcdn.net/ajax/libs/vue-router/4.0.0-rc.1/vue-router.global.min.js',
//     'https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js',
//     'https://cdn.bootcdn.net/ajax/libs/vuex/4.0.0-rc.1/vuex.global.min.js'
//   ]
// }

const webpack = require('webpack')
const path = require('path')

const resolve = (dir) => path.join(__dirname, dir)

module.exports = {
  publicPath: process.env.VUE_APP_PUBLIC_PATH,
  outputDir: 'dist',
  productionSourceMap: process.env.NODE_ENV !== 'production',
  lintOnSave: false,
  //  该对象将会被 webpack-merge 合并入最终的 webpack 配置。
  configureWebpack: {
    plugins: [
      new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /zh-cn/)
    ]
    // if (process.env.NODE_ENV === 'production') {
    //   config.externals = {
    //     'ant-design-vue': 'antd',
    //     vue: 'Vue',
    //     'vue-router': 'VueRouter',
    //     axios: 'axios',
    //     vuex: 'Vuex'
    //   }
    // }
  },
  chainWebpack: (config) => {
    // config.plugin('html').tap(args => {
    //   if (process.env.NODE_ENV === 'production') {
    //     args[0].cdn = cdn
    //   } else {
    //     args[0].cdn = []
    //   }
    //   return args
    // })
    config.plugins.delete('prefetch').delete('preload')
    config.resolve.alias
      .set('@', resolve('src'))
      .set('@components', 'src/components')
      .set('@store', 'src/store')
      .set('@utils', 'src/utils')
  },
  css: {
    loaderOptions: {
      postcss: {
        plugins: [require('tailwindcss'), require('autoprefixer')]
      }
    }
  }
}
